macro 'Gray level wand tool [W]';
var
   x,y:integer;
begin
  Requiresversion(1.55);
  KillROI;
  SetCursor('arrow');
  ShowMessage('Click on the image');
  repeat until button;
  GetMouse(x,y);
  AutoThreshold;
  AutoOutline(x,y);
  SetThreshold(-1);
end;

macro 'Fill Selection, Erase Background';
{ Fills selection to black and sets everything else white }
var
  left,top,width,height:integer;
begin
   GetRoi(left,top,width,height);
   if width=0 then begin
      PutMessage('Selection required.');
      exit;
   end;
   SetForeground(255); { Black }
   SetBackground(0);   { White }
   SelectAll;
   Clear;
   RestoreRoi;
   Fill;
   KillRoi;
end;

